package com.example.online_order.mapper;

import com.example.online_order.pojo.AdminAccount;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.ognl.ASTBitNegate;

import java.util.List;

@Mapper
public interface AdminAccountMapper {

    //    新增，删除，修改，查询（用户名查询  全表查询），

    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    @Insert("insert into adminAccount (id,userName,password,identify,phone,birthday,avatar) values (null,#{userName}, #{password},#{identify},#{phone},#{birthday},#{avatar})")
    public Integer addAdmin(AdminAccount account);
    @Delete("delete from adminAccount where id =#{id}")
    public Integer deleteAdmin(Integer id);

    @Update("update adminAccount set userName= #{userName}, password= #{password}, identify= #{identify}, phone= #{phone}, birthday=#{birthday}, avatar=#{avatar} where id = #{id}")
    public Integer updateAdmin(AdminAccount account);

    @Select("select * from adminAccount")
    public List<AdminAccount> getAllAdmin();

    @Select("select * from adminAccount where userName= #{userName}")
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    public AdminAccount findAdminByUsername(String userName);

    @Select("select * from adminAccount where userName like '%${userName}%' ")
    public List <AdminAccount> findAdminLikeUsername(String username);


    @Select("select * from adminAccount where id= #{id}")
    public  AdminAccount findAdminById(Integer id);


    @Update("update adminAccount set password =#{password} where id=#{id}")
    Integer updateAdminPassword(AdminAccount accountDb);
}
